home *** CD-ROM | disk | FTP | other *** search
- /*
- ==============================================================================
-
- Martian npc_alien(General) and Commander Braddock.
-
- ==============================================================================
- */
-
- #include "g_local.h"
- #include "m_emporer.h"
-
- static int sound_idle;
- static int sound_shoot;
- static int sound_plead;
- static int sound_rant;
- static int sound_soldier_die;
-
-
- void npc_alien_talk(edict_t *self);
- void npc_alien_shoot(edict_t *self);
- void npc_alien_death(edict_t *self);
- void npc_alien_escape(edict_t *self);
-
- void breathe(edict_t *self)
- {
- if (random() < 0.2)
- gi.sound (self, CHAN_VOICE, sound_idle, 1 , ATTN_NORM, 0);
- }
-
- mframe_t npc_alien_frames_stand [] =
- {
- ai_stand, 0, breathe,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
-
- };
- mmove_t npc_alien_move_stand = {FRAME_stand01, FRAME_stand09, npc_alien_frames_stand, NULL};
-
- void npc_alien_stand (edict_t *self)
- {
- self->monsterinfo.currentmove = &npc_alien_move_stand;
- }
-
- void alien_talk (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_rant, 1, ATTN_NORM, 0);
- }
-
- mframe_t npc_alien_frames_talk3 [] =
- {
-
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t npc_alien_move_talk3 = {FRAME_stand01, FRAME_stand09, npc_alien_frames_talk3, npc_alien_shoot};
-
- void npc_alien_talk3 (edict_t *self)
- {
- self->monsterinfo.currentmove = &npc_alien_move_talk3;
- }
-
- mframe_t npc_alien_frames_talk2 [] =
- {
-
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t npc_alien_move_talk2 = {FRAME_stand01, FRAME_stand09, npc_alien_frames_talk2, npc_alien_talk3};
-
- void npc_alien_talk2 (edict_t *self)
- {
- self->monsterinfo.currentmove = &npc_alien_move_talk2;
- }
-
- mframe_t npc_alien_frames_talk [] =
- {
-
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t npc_alien_move_talk = {FRAME_stand01, FRAME_stand09, npc_alien_frames_talk, npc_alien_talk2};
-
- void npc_alien_talk (edict_t *self)
- {
- vec3_t forward, right, start;
-
- AngleVectors (self->s.angles, forward, right, NULL);
- G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_MAKRON_BFG], forward, right, start);
- VectorCopy (self->s.origin, start);
- forward[0] = forward[0] * 52;
- forward[1] = forward[1] * 52;
- VectorAdd(self->s.origin, forward, self->s.origin);
-
- gi.sound (self, CHAN_VOICE, sound_plead, 1 , ATTN_NORM, 0);
-
- VectorCopy (start, self->s.origin);
-
- self->monsterinfo.currentmove = &npc_alien_move_talk;
- }
-
- void npc_alien_blaster (edict_t *self)
- {
- vec3_t forward, right;
- vec3_t start;
- vec3_t end;
- vec3_t dir;
- int flash_number = MZ2_MAKRON_BFG;
-
- AngleVectors (self->s.angles, forward, right, NULL);
- G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start);
- VectorCopy (self->s.origin, start);
- VectorCopy (self->enemy->s.origin, end);
- end[2] += 16;
- VectorSubtract (end, start, dir);
- right[0] = right[0] * 4;
- right[1] = right[1] * 4;
- forward[0] = forward[0] * 64;
- forward[1] = forward[1] * 64;
- VectorAdd(start, right, start);
- VectorAdd(end, forward, end);
- start[2] = start[2] + 4;
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_LEADERBLASTER);
- gi.WritePosition (start);
- gi.WritePosition (end);
- gi.multicast (start, MULTICAST_PHS);
-
- gi.sound (self, CHAN_VOICE, sound_shoot, 1, ATTN_NORM, 0);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_BLASTER);
- gi.WritePosition (end);
- gi.WriteDir (dir);
- gi.multicast (start, MULTICAST_PVS);
- }
-
- void remove_braddock (edict_t *self)
- {
- int n;
- vec3_t forward, right, start;
-
- gi.sound (self, CHAN_VOICE, sound_soldier_die, 1, ATTN_NORM, 0);
- AngleVectors (self->s.angles, forward, right, NULL);
- G_ProjectSource (self->s.origin, monster_flash_offset[MZ2_MAKRON_BFG], forward, right, start);
- VectorCopy (self->s.origin, start);
- forward[0] = forward[0] * 52;
- forward[1] = forward[1] * 52;
- VectorAdd(self->s.origin, forward, self->s.origin);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_EXPLOSION1);
- gi.WritePosition (self->s.origin);
- gi.multicast (self->s.origin, MULTICAST_PVS);
-
- for (n= 0; n < 4; n++)
- ThrowGib (self, "models/objects/gibs/bone/tris.md2", 100, GIB_ORGANIC, EF_GIB);
- for (n= 0; n < 4; n++)
- ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", 100, GIB_ORGANIC, EF_GIB);
-
- self->s.modelindex3 = 0;
-
- VectorCopy(start, self->s.origin);
- }
-
- mframe_t npc_alien_frames_shoot [] =
- {
-
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, npc_alien_blaster,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, remove_braddock
- };
- mmove_t npc_alien_move_shoot = {FRAME_attack01, FRAME_attack10, npc_alien_frames_shoot, npc_alien_death};
-
- void npc_alien_shoot (edict_t *self)
- {
- self->monsterinfo.currentmove = &npc_alien_move_shoot;
- }
-
- mframe_t npc_alien_frames_death [] =
- {
-
- ai_move, 0, alien_talk,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t npc_alien_move_death = {FRAME_rant01, FRAME_rant13, npc_alien_frames_death, npc_alien_escape};
-
- void npc_alien_death (edict_t *self)
- {
- self->monsterinfo.currentmove = &npc_alien_move_death;
- }
-
- void npc_alien_dead (edict_t *self)
- {
- self->s.modelindex = 0;
- self->s.solid = SOLID_NOT;
- self->deadflag = DEAD_DEAD;
- self->takedamage = DAMAGE_NO;
- self->movetype = MOVETYPE_TOSS;
- self->svflags |= SVF_DEADMONSTER;
- self->nextthink = 0;
- gi.linkentity (self);
-
- gi.WriteByte (svc_temp_entity);
- gi.WriteByte (TE_BOSSTPORT);
- gi.WritePosition (self->s.origin);
- gi.multicast (self->s.origin, MULTICAST_PVS);
- }
-
- mframe_t npc_alien_frames_escape [] =
- {
-
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL
- };
- mmove_t npc_alien_move_escape = {FRAME_stand01, FRAME_stand09, npc_alien_frames_escape, npc_alien_dead};
-
- void npc_alien_escape (edict_t *self)
- {
- self->monsterinfo.currentmove = &npc_alien_move_escape;
- }
-
- void SP_npc_alien (edict_t *self)
- {
- if (deathmatch->value)
- {
- G_FreeEdict (self);
- return;
- }
-
- // pre-caches
-
- sound_shoot = gi.soundindex ("martian/shoot2.wav");
- sound_rant = gi.soundindex ("martian/ack2.wav");
- sound_idle = gi.soundindex ("soldier/braddock_breath.wav");
- sound_plead = gi.soundindex ("soldier/braddock_plead.wav");
- sound_soldier_die = gi.soundindex("soldier/death.wav");
-
- self->s.modelindex = gi.modelindex("models/monsters/martian_ambass/tris.md2");
- self->s.modelindex2 = gi.modelindex ("models/monsters/helmet/tris2.md2");
- self->s.modelindex3 = gi.modelindex ("models/npc/braddock/tris.md2");
-
- VectorSet (self->mins, -16, -16, -26);
- VectorSet (self->maxs, 16, 16, 48);
- self->movetype = MOVETYPE_STEP;
- self->solid = SOLID_BBOX;
- self->s.skinnum = 0;
-
- self->max_health = 2500;
- self->health = self->max_health;
- self->gib_health = 0;
- self->mass = 450;
-
- self->classname = "monster_martian_leader";
-
- self->pain = NULL;
- self->die = NULL;
-
- self->monsterinfo.stand = npc_alien_stand;
- self->monsterinfo.walk = npc_alien_talk;
- self->monsterinfo.run = npc_alien_talk;
- self->monsterinfo.dodge = NULL;
- self->monsterinfo.attack = NULL;
- self->monsterinfo.melee = NULL;
- self->monsterinfo.sight = NULL;
- self->monsterinfo.search = NULL;
-
- self->monsterinfo.currentmove = &npc_alien_move_stand;
- self->monsterinfo.scale = MODEL_SCALE;
-
- gi.linkentity (self);
-
- walkmonster_start (self);
- }